package com.mirabelle.juice.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the base database table.
 * 
 */
@Entity
@Table(name="base")
public class Base implements Serializable {
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String comment;
	private Date created;
	private Date modified;
	private String name;
	private Manufacturer manufacturer;
	private Vendor vendor;
	private List<Recipe> recipes;
	private List<UseBase> useBases;

	public Base() {
	}


	@Id
	@SequenceGenerator(name="BASE_ID_GENERATOR", sequenceName="SEQ_BASE_ID")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BASE_ID_GENERATOR")
	@Column(unique=true, nullable=false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}


	@Column(length=2147483647)
	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}


	@Temporal(TemporalType.DATE)
	@Column(nullable=false)
	public Date getCreated() {
		return this.created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}


	@Temporal(TemporalType.DATE)
	public Date getModified() {
		return this.modified;
	}

	public void setModified(Date modified) {
		this.modified = modified;
	}


	@Column(nullable=false, length=255)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	//bi-directional many-to-one association to Manufacturer
	@ManyToOne
	@JoinColumn(name="manufacturer_id")
	public Manufacturer getManufacturer() {
		return this.manufacturer;
	}

	public void setManufacturer(Manufacturer manufacturer) {
		this.manufacturer = manufacturer;
	}


	//bi-directional many-to-one association to Vendor
	@ManyToOne
	@JoinColumn(name="vendor_id")
	public Vendor getVendor() {
		return this.vendor;
	}

	public void setVendor(Vendor vendor) {
		this.vendor = vendor;
	}


	//bi-directional many-to-many association to Recipe
	@ManyToMany(mappedBy="bases")
	public List<Recipe> getRecipes() {
		return this.recipes;
	}

	public void setRecipes(List<Recipe> recipes) {
		this.recipes = recipes;
	}


	//bi-directional many-to-one association to UseBase
	@OneToMany(mappedBy="base")
	public List<UseBase> getUseBases() {
		return this.useBases;
	}

	public void setUseBases(List<UseBase> useBases) {
		this.useBases = useBases;
	}

	public UseBase addUseBas(UseBase useBas) {
		getUseBases().add(useBas);
		useBas.setBase(this);

		return useBas;
	}

	public UseBase removeUseBas(UseBase useBas) {
		getUseBases().remove(useBas);
		useBas.setBase(null);

		return useBas;
	}

}